<template>
  <div>
      <Filters
      block
      :form="searchForm"
      :filterData="filterData"
      @confirm="changePage(1)"
    />
    <div class="container">
      <DataTable rowKey="weightId" :tableData="Data" :tableColumn="tableColumn" :pageConfig="pageConfig" @refresh="getList"></DataTable>
    </div>
  </div>
</template>
<script lang='ts'>
import { Component, Watch, Vue } from 'vue-property-decorator'

@Component
export default class acceptanceConfig extends Vue {
  pageConfig: any = {
    current: 1,
    total: 10,
    pageSize: 10,
    onChange: this.changePage
  };
  listType:any = [
      {
          value: '',
          label: '全部'
      },
      {
          value: 'no',
          label: '未与验收单关联'
      },
      {
          value: 'one',
          label: '与单张验收单关联'
      },
      {
          value: 'duo',
          label: '与多张验收单关联'
      }
  ]
  searchForm: any = {
    searchValue: '',
    refStatus: undefined,
    date: ''
  }
  get filterData () {
    return {
        date: {
            label: '日期筛选',
            type: 'daterange3',
            width: 200,
            template: {
                clearable: true
            }

        },
        refStatus: {
            label: '磅单关联状态',
            type: 'select',
            width: 200,
            template: {
            placeholder: '请选择磅单关联状态',
            clearable: true,
            filterable: true,
            options: this.listType
            }
        },
        searchValue: {
            label: '磅单流水号/电子磅单ID/客户名称',
            type: 'input',
            template: {
              placeholder: '磅单流水号/电子磅单ID/客户名称',
              clearable: true
            }
        }

    }
  }
  Data: any[] = []
  tableColumn: any = {
    index: {
      label: '序号',
      width: 120
    },
    weightSerial: {
      label: '磅单流水号'
    },
    trackScaleId: {
      label: '电子磅单ID'
    },
    projectName: {
      label: '地磅关联项目'
    },
    createTime: {
      label: '磅单数据推送时间'
    },
    refDeliveryNum: {
        label: '关联验收单数'
    },
    action: {
          label: '操作',
          width: 120,
          template: [
            {
            tag: 'router-link',
            text: '详情',
            query: {
                _alias: 'detail',
                weightId: ''
            },
            path: '/acceptance/listRecord/listRecordDetails'
            }
        ]
    }
  }
  changePage (val: number) {
    this.pageConfig.current = val;
    this.getList();
  }
  // 获取列表数据
  getList () {
      console.log(this.searchForm.date)
      let data = {
          page: this.pageConfig.current,
          size: this.pageConfig.pageSize,
          searchValue: this.searchForm.searchValue,
          refStatus: this.searchForm.refStatus,
          StartDate: this.searchForm.date[0],
          endDate: this.searchForm.date[1]
      }
      this.$api.weightWeightListFetch(data).then((res:any) => {
          if (res.code == 0) {
              res.data.records.map((item:any, index:any) => {
                  item.index = this.pageConfig.pageSize * (this.pageConfig.current - 1) + (index + 1)
              })
              this.Data = res.data.records
              this.pageConfig.total = res.data.total
          }
      }).catch()
  }
  init () {
      this.getList()
  }
}
</script>
<style lang='scss' scoped></style>
